<template>
	<view>
		<u-empty text="暂时没有数据哦~" mode="message" :show="commentlist.length==0" :color="color"></u-empty>
	<view v-if="commentlist.length!=0" class="index-comment">
		<view>餐馆评价</view>
		<view>
			<ls-loading v-if="pageLoading" :text="text"></ls-loading>
			<view v-for="(item,index) in rate" :key="index">
				<text>{{item.text}}</text>
				<view>
					<u-rate :value="item.rate" :colors="colors" :size="30" disabled></u-rate>
				</view>
				<text>{{item.rate}}</text>
			</view>
		</view>
		<view>
			<view v-for="item in commentlist" :key="item._id">
				<view>
					<image :src="item.userinfo.avatar"></image>
					<view>
						<text>{{item.userinfo.nickname}}</text>
						<view>{{item.createtime}}</view>
					</view>
				</view>
				<view style="margin-bottom: 14rpx;margin-top: 10rpx;">{{item.comment}}</view>
				<view class="intro"><span style="color: rgb(162 162 162);font-size: 13px;">综合评分:{{item.averagescore}}分</span></view>
				<view class="dish">
					<view class="dishname"><span v-for="(name,idx) in item.dishlist" :key="'dish'+idx">{{name.name}};</span><span>共{{item.dishlist.length}}件菜品</span></view>
				</view>
				<div class="comment" v-if="!item.response==''">
					<h6>掌柜回复:</h6>
					{{item.response}}
					</div>
				</view>
		</view>
		<!-- <view>查看全部评论(37)</view> -->
		<u-divider color="#9ea4aa;" half-width="200" border-color="#9ea4aa">没有更多了</u-divider>
		<view v-if="pageLoading==false" @click="handleGoOrder">
			<image src="../../static/ic_order@2x.png"></image>
			<text>去点菜</text>
		</view>
	</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				color: '#000000',
				pageLoading:true,
				text:'Loading...',
				rate:[],
				commentlist:[]
			}
		},
		created() {
		this.getComment()
		},
		methods:{
			handleGoOrder(){
				uni.switchTab({
					url:'../order/order'
				})
			},
			getComment(){
				this.$u.post('/comment/getAllComment').then(res=>{
					console.log(res,'评价');
					this.commentlist=res.data.data.comment
					this.rate=res.data.data.rate
					this.pageLoading=false
				})
			}
		}
	}
</script>

<style lang="scss">
	@import '../../static/css/index.scss';
	.comment{
		width: 95%;min-height:30rpx;margin: 10px auto;border: 2px solid #eee;box-shadow: 0px 0px 1px 0px; background: #f3f4f6;
		font-size: 13px;
		padding: 4px 4px 10px 4px;
	}
	.dishname span{
		color: #686868;
		    font-size: 13px;
	}
</style>
